# Create your views here.
from cookland.ricettario.models import Category
from cookland.ricettario.models import Cuisine
from cookland.ricettario.models import Season
from django.http import HttpResponseRedirect

def install_db(request):

    if len(Category.objects.all()) == 0:
        cats = ['Antipasti', 'Primi Piatti', 'Secondi Piatti', 'Contorni', 'Dessert']
        for c in cats:
            cat = Category(name=c)
            cat.save()
    
    if len(Cuisine.objects.all()) == 0:
        cuis = ['Italiana', 'Cinese', 'Giapponese', 'Messicano', 'Argentina', 'Africana', 'Altro']
        for c in cuis:
            cui = Cuisine(name=c)
            cui.save()

    if len(Season.objects.all()) == 0:
        seas = ['primavera', 'estate', 'autunno', 'inverno', 'tutto l\'anno']
        for s in seas:
            sea = Season(name=s)
            sea.save()

    return HttpResponseRedirect('/recipes/')


